using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.VFX;

public class BuffTimeBurn:BuffBase {
	public override string spriteName => "timeburn";

	public BuffTimeBurn(BuffSlot buffSlot,Mob mob) : base(buffSlot,mob) {

	}
	VisualEffect vfx;
	float timeAfterTick;

	protected override void Update() {
		base.Update();
		timeAfterTick+=Time.deltaTime;
		if(!vfx) vfx=ParticleManager.Create("CharacterBlueFire",mob.position).GetComponent<VisualEffect>();
		vfx.transform.position=mob.spriteRenderer.bounds.min+Vector3.down*0.01f;
		vfx.SetFloat("Intensity",stacks);
		vfx.SetVector2("Size",mob.spriteRenderer.bounds.size);

		mob.ChangeLocalTimeScale(0.7f);

		if(timeAfterTick>0.25f) {
			timeAfterTick-=0.25f;
			DamageStats damage = new DamageStats();
			damage.amount=8f;
			damage.damageElement=DamageElement.Fire;
			damage.damageType=DamageType.OverTime;
			damage.isComposition=true;
			damage.createParticles=false;
			mob.Damage(damage);

			stacks-=0.2f;
			if(stacks<=0) RemoveSelf();
		}

	}

	protected override void OnRemove() {
		base.OnRemove();
		vfx.gameObject.SetActive(false);
	}
}
